from abc import ABC, abstractmethod

class AIAssistant(ABC):
    """AI助手基类，定义通用属性与抽象方法"""
    def __init__(self, aid: str, name: str, type_: str, version: str, is_online: bool, ability_score: int):
        # 父类属性：编号、名称、类型、版本号、是否在线、能力评分
        self.aid = aid
        self.name = name
        self.type_ = type_
        self.version = version
        self.is_online = is_online
        # 能力评分合法性校验（0-100）
        if 0 <= ability_score <= 100:
            self.ability_score = ability_score
        else:
            raise ValueError("能力评分必须在0-100之间")

    @abstractmethod
    def execute_task(self, task_content: str) -> str:
        """抽象方法：执行任务，子类需根据类型实现具体逻辑"""
        pass

    def get_detail_info(self) -> str:
        """获取助手详细信息（用于ID查询）"""
        status_icon = "🟢在线" if self.is_online else "🔴离线"
        return (f"✅ 查询结果: ID: {self.aid}, 名称: {self.name}, 类型: {self.type_}, "
                f"版本: {self.version}, 状态: {status_icon}, 能力评分: {self.ability_score} [{self.type_}]")

    def __str__(self) -> str:
        """获取助手简要信息（用于列表展示）"""
        status = "在线" if self.is_online else "离线"
        return (f"ID: {self.aid}, 名称: {self.name}, 类型: {self.type_}, 版本: {self.version}, "
                f"状态: {status}, 能力评分: {self.ability_score} [{self.type_}]")